package cc.forgemod.customicon.common.network;

import cc.forgemod.customicon.common.CustomIcon;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import net.minecraftforge.fml.relauncher.Side;

public class PacketHandler extends APacketHandler {

    public static final SimpleNetworkWrapper CHANNEL = NetworkRegistry.INSTANCE.newSimpleChannel(CustomIcon.MODID.toLowerCase());

    @Override
    public <REQ extends PacketBridge, REPLY extends PacketBridge> void regPacket(Class<? extends PacketBridge<REQ, REPLY>> pHandler, Class<REQ> pRMsgType, int pId, CSide side) {
        CHANNEL.registerMessage(pHandler, pRMsgType, pId, side == CSide.CLIENT ? Side.CLIENT : Side.SERVER);
    }

    @Override
    public void sendTo(PacketBridge message, EntityPlayerMP player) {
        CHANNEL.sendTo(message, player);
    }

    @Override
    public void sendAll(PacketBridge message) {
        CHANNEL.sendToAll(message);;
    }

}
